

package com.rshang.rsdp.controller;

import com.rshang.rsdp.bean.DataGrid;
import com.rshang.rsdp.bean.Response;
import com.rshang.rsdp.service.ITbRsdlRyxxService;
import com.rshang.rsdp.util.excel.ExcelView;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
 * Copyright (c) 2017. Rushang Co.Ltd All Rights Reserved.
 * 项目名称:rsdp-base
 * 文件名称:DbrwController.java
 * 功能简介:<br/>
 *
 * @create 2017-09-02
 * @author zhangjun
 */
@Controller
@RequiresAuthentication
@RequestMapping("/dbrw")
public class DbrwController extends BaseController {

    @Autowired
    ITbRsdlRyxxService ryService;

    @ResponseBody
    @RequestMapping("/wbcx/manage")
    public DataGrid wbcx(HttpServletRequest request) {
        //修改为获取全部数据
        //return ryService.getRyxxList(getPage(),request,this.getSubject().hasRole("业务经理")?"":this.getSessionUser().getUserId(),"wb");
        return ryService.getRyxxList(getPage(), request, "", "wb");
    }

    @RequestMapping("/wbcx/wbSave")
    @ResponseBody
    public Response rylzWbSave() {
        return ryService.wbSave(request, this.getSessionUser().getUserId());
    }

    @ResponseBody
    @RequestMapping("/lzcx/manage")
    public DataGrid lzcx(HttpServletRequest request) {
        //修改为获取全部数据
        //return ryService.getRyxxList(getPage(), request, this.getSubject().hasRole("业务经理") ? "" : this.getSessionUser().getUserId(), "lz");
        return ryService.getRyxxList(getPage(), request, "", "lz");
    }

    @RequestMapping("/wbcx/export")
    public ModelAndView wbcxExport(HttpServletRequest request, HttpServletResponse response) {
        //修改为获取全部数据
        //Workbook wb = ryService.ryListExcelExport(request, this.getSubject().hasRole("业务经理") ? "" : this.getSessionUser().getUserId(), "wb");
        Workbook wb = ryService.ryListExcelExport(request, "", "wb");
        return new ModelAndView(new ExcelView("wbryxx.xls", wb));
    }

    @RequestMapping("/lzcx/export")
    public ModelAndView lzcxExport(HttpServletRequest request, HttpServletResponse response) {
        //修改为获取全部数据
        //Workbook wb = ryService.ryListExcelExport(request, this.getSubject().hasRole("业务经理") ? "" : this.getSessionUser().getUserId(), "lz");
        Workbook wb = ryService.ryListExcelExport(request, "", "lz");
        return new ModelAndView(new ExcelView("lzryxx.xls", wb));
    }

    @RequestMapping("/lzcx/ryjp")
    @ResponseBody
    public Response ryjpSave() {
        return ryService.ryjpSave(request, this.getSessionUser().getUserId());
    }

    @RequestMapping("/lzcx/ryyc")
    @ResponseBody
    public Response ryycSave() {
        return ryService.ryycSave(request, this.getSessionUser().getUserId(),"0");
    }
    @RequestMapping("/lzcx/rydjpyc")
    @ResponseBody
    public Response rydjpycSave() {
        return ryService.ryycSave(request, this.getSessionUser().getUserId(),"1");
    }
    @RequestMapping("/lzcx/rydjp")
    @ResponseBody
    public Response rydjpSave() {
        return ryService.ryDjpSave(request, this.getSessionUser().getUserId());
    }
    
    @ResponseBody
    @RequestMapping("/jpcx/manage")
    public DataGrid jpcx(HttpServletRequest request) {
        return ryService.getRyxxJpList(getPage(), request, "");
    }
    
    @RequestMapping("/jpcx/export")
    public ModelAndView jpcxExport(HttpServletRequest request, HttpServletResponse response) {
        Workbook wb = ryService.ryjpListExcelExport(request, "");
        return new ModelAndView(new ExcelView("jpryxx.xls", wb));
    }

}
